package com.car.carcontrol;

import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Backup {
//    int iconW0 = 145;
//    int iconH0 = 152;
//    int iconW = iconW0*width/1280;
//    int iconH = iconH0*height/480;


//    private List<Map<Integer, ImageView>> zmList = new ArrayList<Map<Integer, ImageView>>();
//    private List<Map<Integer, ImageView>> fwList = new ArrayList<Map<Integer, ImageView>>();
//    private ImageView iv_light_level_0;
//    private ImageView iv_light_fw_level_0;

//    Object[] allParam = new Object[]{
//
//            new Object[]{"iv", new Rect(0*width/1280, 0*height/480, 1280*width/1280, 480*height/480), R.drawable.bg, false, new byte[]{0x00,0x01,0x02,0x03,0x04,0x05}},
//            new Object[]{"iv", new Rect(0*width/1280, 0*height/480, 246*width/1280, 477*height/480), R.drawable.bg_left, false, new byte[]{0x00,0x01,0x02,0x03,0x04,0x05}},
//            new Object[]{"iv", new Rect(475*width/1280, 85*height/480, 483*width/1280, 30*height/480), R.drawable.bg_top, false, new byte[]{0x00,0x01,0x02,0x03,0x04,0x05}},
//
//            new Object[]{"lrsv", new Rect(407*width/1280, 40*height/480, 655*width/1280, 110*height/480), names, 24, Color.WHITE},
//            new Object[]{"fl", new Rect(246*width/1280, 140*height/480, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)},
//
//            new Object[]{"tv", new Rect(27*width/1280, 20*height/480, 0, 0), "温度", 18, 0xFF4785E2, false, new byte[]{0x00,0x01,0x02,0x03,0x04,0x05}},
//            new Object[]{"tv", new Rect(1032*width/1280, 19*height/480, 0, 0), "时间", 18, 0xFF4785E2, false},
//            new Object[]{"tv", new Rect(1145*width/1280, 28*height/480, 0, 0), "日期", 10, 0xFF4785E2, false},
//            new Object[]{"tv", new Rect(1240*width/1280, 19*height/480, 0, 0), "UI", 18, 0xFF4785E2, true},
//
//            new Object[]{"tv", new Rect(64*width/1280, 90*height/480, 0, 0), "投屏", 19, Color.WHITE, true},
//            new Object[]{"tv", new Rect(76*width/1280, 150*height/480, 0, 0), "视频", 19, Color.WHITE, true},
//            new Object[]{"tv", new Rect(90*width/1280, 210*height/480, 0, 0), "音乐", 19, Color.WHITE, true},
//            new Object[]{"tv", new Rect(91*width/1280, 270*height/480, 0, 0), "蓝牙", 19, Color.WHITE, true},
//            new Object[]{"tv", new Rect(74*width/1280, 330*height/480, 0, 0), "网络", 19, Color.WHITE, true},
//            new Object[]{"tv", new Rect(64*width/1280, 390*height/480, 0, 0), "设置", 19, Color.WHITE, true},
//
//            new Object[]{"mcv", new Rect(0*width/1280, 0*height/480, 1280*width/1280, 480*height/480), "小米时钟", 19, 0xFF237EAD, true},
//    };

//        if(frags==null){
//            frags = new Fragment[]{new Fragment_First(), new Fragment_Second(), new Fragment_Third(), new Fragment_Fourth(), new Fragment_Fifth(), new Fragment_Sixth()};
//        }else{
//            Log.e("ma===onResume3", width+"==="+height+"==="+frags.length);
//        }

//        if(mapTab==null){
//            names = new String[]{"灯光", "码表", "净化器", "天窗", "多媒体", "空调"};
//            frags = new Fragment[]{new Fragment_First(), new Fragment_Second(), new Fragment_Third(), new Fragment_Fourth(), new Fragment_Fifth(), new Fragment_Sixth()};
//        }else{
//            Log.e("ma===onResume2", width+"==="+height+"==="+names.length);
//
//            int i=0;
//            names = new String[mapTab.size()];
//            frags = new Fragment[mapTab.size()];
//            for(Map.Entry<String, Fragment> entry:mapTab.entrySet()){
//                Log.e("map===", entry.getKey()+"--->"+entry.getValue());
//                names[i] = entry.getKey();
//                frags[i] = entry.getValue();
//
//                i++;
//            }
//        }

//        String[] names = new String[]{"灯光", "净化器", "天窗", "多媒体", "空调"};
//        String[] names = new String[]{"灯光", "码表", "净化器", "天窗", "多媒体", "空调", "电器"};
//        String[] names = list.toArray();

//    wName1 = "";
//    wName2 = "";
//    wName3 = "";
//    wName4 = "";
//    wName5 = "";
//    wName6 = "";

    //                                imgSrc1=0;
//                                imgSrc2=0;
//                                imgSrc3=0;
//                                imgSrc4=0;
//                                imgSrc5=0;
//                                imgSrc6=0;


//    private String bytesToString(byte[] arg) {
//        String result = new String();
//        if (arg != null) {
//            for (int i = 0; i < arg.length; i++) {
//
//                Log.e("bytesToString===1", arg[i]+"===");   //030AF2
//
//                result = result
//                        + (Integer.toHexString(
//                        arg[i] < 0 ? arg[i] + 256 : arg[i]).length() == 1 ? "0"
//                        + Integer.toHexString(arg[i] < 0 ? arg[i] + 256
//                        : arg[i])
//                        : Integer.toHexString(arg[i] < 0 ? arg[i] + 256
//                        : arg[i])) + " ";
//            }
//            return result;
//        }
//        return "";
//    }

    //    public static String byteArrayTohexString(byte[] bytes) {
//
//        for(int i = 0; i < str.length() / 2; i++) {
//
//        if(str == null || str.trim().equals("")) {
//            return new byte[0];
//        }
//
//        byte[] bytes = new byte[str.length() / 2];
//        for(int i = 0; i < str.length() / 2; i++) {
//            String subStr = str.substring(i * 2, i * 2 + 2);
//            bytes[i] = (byte) Integer.parseInt(subStr, 16);
//        }
//
//        Log.e("StringToByte===1", bytes+"==="+bytes[0]);
//
//        return bytes;
//    }

//    //        private LayoutInflater inflater;
//
//    public MyAdapter(Context context){
//        super(context);
////            this.inflater = LayoutInflater.from(context);
//    }


//    ViewTreeObserver vto = framelayout.getViewTreeObserver();
//                vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
//        @Override
//        public void onGlobalLayout() {
//            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
//                framelayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
//            } else {
//                framelayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
//            }
//            widthFl  = framelayout.getMeasuredWidth();
//            heightFl = framelayout.getMeasuredHeight();
//
//            Log.e("onGlobalLayout===", widthFl+"==="+heightFl);
//
//        }
//    });
//
//                Log.e("onCreate===", framelayout.getMeasuredWidth()+"==="+framelayout.getMeasuredHeight());

    // Find the center of the container
//        final float centerX = framelayout.getWidth() / 2.0f;
//        final float centerX = framelayout.getWidth() / 2.0f;
//        final float centerY = framelayout.getHeight();
//        final float centerX = framelayout.getWidth() * 2.0f;

//        final float centerX = framelayout.getWidth();
//        final float centerY = framelayout.getHeight();
//        start = 0;
//        end = -90;

//        rotation.setAnimationListener(new DisplayNextView(0, 0, zheng, new Fragment_First()));// 添加监听执行现实内容的切换
//        rotation.setAnimationListener(new DisplayNextView(width/2, 0, zheng, new Fragment_Second()));

    //                tration.detach(fromFragment);
//                fromFragment.de

//                framelayout.removeAllViews();
//                framelayout2.removeAllViews();
//                secondFragment
//                tration.remove(toFragment).detach(toFragment).remove(fromFragment).detach(fromFragment).commit();
//                manager.beginTransaction().add(id, toFragment).add(id2, fromFragment).commit();
//                tration.hide(fromFragment);

//                tration.replace(id, fromFragment).replace(id2, toFragment).commit();


//            tration.replace(id, toFragment, Fragment_Second.TAG).commit();
//            tration.replace(id, toFragment, Fragment_Second.TAG).commitAllowingStateLoss();
//            tration.remove(toFragment);

//    private void ReplaceFragmentMethod() {
//        FragmentTransaction tration = getSupportFragmentManager().beginTransaction();
//        tration.replace(id, new Fragment_First());
//        tration.commit();
//    }

//    private final class DisplayNextView implements Animation.AnimationListener {
//        private final boolean mPosition;
//        private final Fragment mfragment;
//
//        float centerX;
//        float centerY;
//
//        private DisplayNextView(float x, float y, boolean zheng, Fragment fragment) {
//            centerX = x;
//            centerY = y;
//            mPosition = zheng;
//            mfragment = fragment;
//        }
//
//        public void onAnimationStart(Animation animation) {
//            framelayout.post(new SwapViews(centerX, centerY, mPosition, mfragment));// 添加新的View
//        }
//
//        public void onAnimationEnd(Animation animation) {
//
//        }
//
//        public void onAnimationRepeat(Animation animation) {
//        }
//    }


//    private final class SwapViews implements Runnable {
//        private final boolean mPosition;
//        private final Fragment mfragment;
//        float centerX;
//        float centerY;
//
//        public SwapViews(float x, float y, boolean position, Fragment fragment) {
//            centerX = x;
//            centerY = y;
//            mPosition = position;
//            mfragment = fragment;
//        }
//
//        public void run() {
////            final float centerX = framelayout.getWidth() / 2.0f;
////            final float centerY = framelayout.getHeight() ;
////            float centerX = -framelayout.getWidth();
////            float centerY = 0;
//            Util_Rotate3DAnimation rotation;
//            FragmentTransaction tration = getSupportFragmentManager().beginTransaction();
//            tration.replace(id, mfragment);
//
//            Log.e("run===", mPosition+"==="+centerX+"==="+centerY);
//
////            centerX = 0;
////            centerY = 0;
////            start = 0;
////            end = 90;
//
//            if (mPosition) {
//                rotation = new Util_Rotate3DAnimation(framelayout, widthFl, dx,0, 90, centerX, centerY, 0.0f, false, isEnd);
//            } else {
//                rotation = new Util_Rotate3DAnimation(framelayout, widthFl, dx,90, 0, centerX, centerY, 310.0f, false, isEnd);
//            }
//            tration.commit();
//            rotation.setDuration(1000);
//            rotation.setFillAfter(true);
//            rotation.setInterpolator(new DecelerateInterpolator());
//            framelayout.startAnimation(rotation);
//        }
//    }

//            Object[] obj = (Object[])allParam[i];
//            ArrayList list = (ArrayList)allParam[i];
//            Object[] obj = list.toArray();

//                et.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
//                et.setKeyListener(DigitsKeyListener.getInstance("ABCDEF"));
//                et.setInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
//                et.setFilters(new InputFilter[]{new InputFilter.LengthFilter(6)});


//                            if(btnId==1 && "".equals(wName1)){
//                                iv_add1.setImageResource(R.drawable.add_icon);
//                            }else if(btnId==2 && "".equals(wName2)){
//                                iv_add2.setImageResource(R.drawable.add_icon2);
//                            }else if(btnId==3 && "".equals(wName3)){
//                                iv_add3.setImageResource(R.drawable.add_icon3);
//                            }else if(btnId==4 && "".equals(wName4)){
//                                iv_add4.setImageResource(R.drawable.add_icon4);
//                            }else if(btnId==5 && "".equals(wName5)){
//                                iv_add5.setImageResource(R.drawable.add_icon5);
//                            }else if(btnId==6 && "".equals(wName6)){
//                                iv_add6.setImageResource(R.drawable.add_icon6);
//                            }

//                            if(imgId==R.drawable.add_icon && "".equals(wName1)){
//                                iv.setImageResource(R.drawable.add_iconf);
//                                btnId = 1;
//                            }else if(imgId==R.drawable.add_iconf && "".equals(wName1)){
//                                iv.setImageResource(R.drawable.add_icon);
//                                btnId = 0;
//                            }else if(imgId==R.drawable.add_icon2 && "".equals(wName2)){
//                                iv.setImageResource(R.drawable.add_icon2f);
//                                btnId = 2;
//                            }else if(imgId==R.drawable.add_icon2f && "".equals(wName2)){
//                                iv.setImageResource(R.drawable.add_icon2);
//                                btnId = 0;
//                            }else if(imgId==R.drawable.add_icon3 && "".equals(wName3)){
//                                iv.setImageResource(R.drawable.add_icon3f);
//                                btnId = 3;
//                            }else if(imgId==R.drawable.add_icon3f && "".equals(wName3)){
//                                iv.setImageResource(R.drawable.add_icon3);
//                                btnId = 0;
//                            }else if(imgId==R.drawable.add_icon4 && "".equals(wName4)){
//                                iv.setImageResource(R.drawable.add_icon4f);
//                                btnId = 4;
//                            }else if(imgId==R.drawable.add_icon4f && "".equals(wName4)){
//                                iv.setImageResource(R.drawable.add_icon4);
//                                btnId = 0;
//                            }else if(imgId==R.drawable.add_icon5 && "".equals(wName5)){
//                                iv.setImageResource(R.drawable.add_icon5f);
//                                btnId = 5;
//                            }else if(imgId==R.drawable.add_icon5f && "".equals(wName5)){
//                                iv.setImageResource(R.drawable.add_icon5);
//                                btnId = 0;
//                            }else if(imgId==R.drawable.add_icon6 && "".equals(wName6)){
//                                iv.setImageResource(R.drawable.add_icon6f);
//                                btnId = 6;
//                            }else if(imgId==R.drawable.add_icon6f && "".equals(wName6)){
//                                iv.setImageResource(R.drawable.add_icon6);
//                                btnId = 0;
//                            }

//        for(Map.Entry<String, Fragment> entry:Config.mapTab.entrySet()){
//            Log.e("sa===map", entry.getKey()+"--->"+entry.getValue());
//        }

    //        Gson gson = new Gson();
//
//        String rect = gson.toJson(new Rect(609*width/1280-width_d, 334*height/480-height_d, 0, 0));
//        String bytes = gson.toJson(new byte[]{0x00,0x01,0x02,0x03,0x04,0x05});
//        String obj = gson.toJson(new Object[]{"tv", rect, wName, 20, Color.WHITE, false, bytes});
//
//        rect = gson.toJson(new Rect(809*width/1280-width_d, 334*height/480-height_d, 0, 0));
//        bytes = gson.toJson(new byte[]{0x00,0x01,0x02,0x03,0x04,0x05});
//        String obj2 = gson.toJson(new Object[]{"tv", rect, wName2, 20, Color.WHITE, false, bytes});
//
//        rect = gson.toJson(new Rect(1009*width/1280-width_d, 334*height/480-height_d, 0, 0));
//        bytes = gson.toJson(new byte[]{0x00,0x01,0x02,0x03,0x04,0x05});
//        String obj3 = gson.toJson(new Object[]{"tv", rect, wName3, 20, Color.WHITE, false, bytes});
//
//        rect = gson.toJson(new Rect(609*width/1280-width_d, 434*height/480-height_d, 0, 0));
//        bytes = gson.toJson(new byte[]{0x00,0x01,0x02,0x03,0x04,0x05});
//        String obj4 = gson.toJson(new Object[]{"tv", rect, wName4, 20, Color.WHITE, false, bytes});
//
//        rect = gson.toJson(new Rect(809*width/1280-width_d, 434*height/480-height_d, 0, 0));
//        bytes = gson.toJson(new byte[]{0x00,0x01,0x02,0x03,0x04,0x05});
//        String obj5 = gson.toJson(new Object[]{"tv", rect, wName5, 20, Color.WHITE, false, bytes});
//
//        rect = gson.toJson(new Rect(1009*width/1280-width_d, 434*height/480-height_d, 0, 0));
//        bytes = gson.toJson(new byte[]{0x00,0x01,0x02,0x03,0x04,0x05});
//        String obj6 = gson.toJson(new Object[]{"tv", rect, wName6, 20, Color.WHITE, false, bytes});
//
//        String[] objs = new String[]{obj, obj2, obj3, obj4, obj5, obj6};
//
//        Object[] allParam = new Object[total];
//
//        for (int i = 0; i < total; i++) {
//            allParam[i] = objs[i];
//        }
//
//        SharedPreferencesUrls.getInstance().putString(Config.mapSp.get(name), gson.toJson(allParam));

//        Intent intent = new Intent();
////      intent.putExtra("QR_CODE", deviceuuid);
//        setResult(RESULT_OK, intent);
//        finish();


//                    int x = (14+100*position+(int)dx)*width/1280-hlv.mCurrentX;

////            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
//            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(100*width/1280, FrameLayout.LayoutParams.WRAP_CONTENT);
//            layout.setLayoutParams(layoutParams);
//            layout.setGravity(Gravity.CENTER);

//            String tvName = bean.getName();

//            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(rect.right, rect.bottom);
//            params.setMargins(rect.left, rect.top, rect.right, rect.bottom);
//            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(hlv_iconW, hlv_iconH);
//            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100*width/1280, FrameLayout.LayoutParams.WRAP_CONTENT);

//            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
//            params.setMargins(14*width/1280, 370*height/480, 14*width/1280+14*width/1280, 0);
//            params.width=hlv_iconW;
//            params.height=hlv_iconH;

//            params = new FrameLayout.LayoutParams(100*width/1280, FrameLayout.LayoutParams.WRAP_CONTENT);
//            params.setMargins(0*width/1280, 370*height/480, 0, 0);
//            TextView tv = new TextView(context);
//            tv.setText("");
//            tv.setTextSize(16);
//            tv.setTextColor(Color.WHITE);
//            tv.setGravity(Gravity.CENTER);
//            layout.addView(tv, params);

//            if (null == convertView) {
//                convertView = inflater.inflate(R.layout.item_add_widget, null);
//            }
//            ImageView imageView = BaseViewHolder.get(convertView, R.id.item_iv);
//            TextView tv_name = BaseViewHolder.get(convertView, R.id.item_name);
//
//            WidgetBean bean = getDatas().get(position);
//
//            Log.e("awa===getView", bean.getName()+"==="+bean.getBytes());
//
//            String tvName = bean.getName();
//            int imgSrc = bean.getImgSrc();
//
//            tv_name.setText(tvName);
//            imageView.setImageResource(imgSrc);

//                    new Object[]{"tv", new Rect(609*width/1280-width_d, 334*height/480-height_d, 0, 0), "温度", 20, Color.WHITE, false, new byte[]{0x00,0x01,0x02,0x03,0x04,0x05}},
//                    new Object[]{"tv", new Rect(809*width/1280-width_d, 334*height/480-height_d, 0, 0), "风速", 20, Color.WHITE, false, new byte[]{0x00,0x01,0x02,0x03,0x04,0x05}},


//            MainActivity.frags = new Fragment[]{new Fragment_First(), new Fragment_Second(), new Fragment_Third(), new Fragment_Fourth(), new Fragment_Fifth(), new Fragment_Sixth()};
//            MainActivity.names = new String[]{"灯光", "码表", "净化器", "天窗", "多媒体", "空调"};

//            MainActivity.frags = new Fragment[]{new Fragment_First(), new Fragment_Third(), new Fragment_Fourth(), new Fragment_Fifth(), new Fragment_Sixth()};
//            MainActivity.names = new String[]{"灯光", "净化器", "天窗", "多媒体", "空调"};

//            Fragment[] frags = new Fragment[]{new Fragment_First(), new Fragment_Third(), new Fragment_Fourth(), new Fragment_Fifth(), new Fragment_Sixth()};


//            HashMap<String, Fragment> mapTab = new HashMap<>();
//            mapTab.put("灯光", new Fragment_First());
//            mapTab.put("净化器", new Fragment_Third());
//            mapTab.put("天窗", new Fragment_Fourth());
//            mapTab.put("多媒体", new Fragment_Fifth());
//            mapTab.put("空调", new Fragment_Sixth());

//            SharedPreferencesUrls.getInstance().putHashMap("mapTab", mapTab);
//            SharedPreferencesUrls.getInstance().putObject("frags", frags);
//            SharedPreferencesUrls.getInstance().putObject("names", MainActivity.names);



//            String[] names = new String[]{"灯光", "码表", "净化器", "天窗", "多媒体", "空调", "电器"};
//            SharedPreferencesUrls.getInstance().putObject("names", names);

//            new Object[]{"lrsv", new Rect(407*width/1280, 340*height/480, 655*width/1280, 110*height/480), new String[]{"灯光", "码表", "净化器", "天窗", "多媒体", "空调"}, 24, Color.WHITE},
//            new Object[]{"fl", new Rect(246*width/1280, 0*height/480, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)},


    //    int[] imgSrc = new int[]{
//            R.drawable.bg,
//            R.drawable.bg_left,
//            R.drawable.bg_top
//    };
//
//    //1280*480
//    Rect[] allRect = new Rect[]{
//            new Rect(0*width/1280, 0*height/480, 1280*width/1280, 480*height/480),
//            new Rect(0*width/1280, 0*height/480, 246*width/1280, 477*height/480),
//            new Rect(475*width/1280, 85*height/480, 483*width/1280, 30*height/480)
//    };

//    private Fragment firstFragment = new Fragment_First();
//    private Fragment secondFragment = new Fragment_Second();
//    private Fragment thirdFragment = new Fragment_Third();
//    private Fragment fourthFragment = new Fragment_Fourth();

}

//        framelayout = (FrameLayout) findViewById(R.id.fragment_content);
//        framelayout2 = (FrameLayout) findViewById(R.id.fragment_content2);
//        ReplaceFragmentMethod();


//        mLoopRotarySwitchView = (LoopRotarySwitchView) findViewById(R.id.mLoopRotarySwitchView);

//                mLoopRotarySwitchView.setOnItemClickListener(new OnItemClickListener() {
//                    @Override
//                    public void onItemClick(int item, View view) {
//
//                    }
//                });

//mLoopRotarySwitchView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
//@Override
//public void onFocusChange(View v, boolean hasFocus) {
//        }
//        });
//
//
//        mLoopRotarySwitchView.setOnHoverListener(new View.OnHoverListener() {
//@Override
//public boolean onHover(View v, MotionEvent event) {
////                      Log.e("onHover===", v+"==="+event.getAction());
//        return false;
//        }
//        });
//
//        mLoopRotarySwitchView.requestFocus();

//                miClockView.setOnContextClickListener(new View.OnContextClickListener() {
//                    @Override
//                    public boolean onContextClick(View v) {
//                        Log.e("mcv===onContextClick", "===");
//
//                        miClockView.setVisibility(View.GONE);
//
//                        return false;
//                    }
//                });
//
//                miClockView.setOnClickListener(new View.OnClickListener() {
//
//                    @Override
//                    public void onClick(View v) {
//                        Log.e("miClockView===onClick", "===");
//
//                        miClockView.setVisibility(View.GONE);
//                    }
//                });

//
//    else if(imgSrc==R.drawable.light_level_0){
//            iv_light_level_0 = iv;
//            }else if(imgSrc==R.drawable.light_fw_level_0){
//            iv_light_fw_level_0 = iv;
//            }

//                TextView tv=new TextView(this);
//                tv.setText("灯光");
//                tv.setTextColor(Color.WHITE);
//                tv.setTextSize(30);
//                mLoopRotarySwitchView.addView(tv);
//
//                TextView tv2=new TextView(this);
//                tv2.setText("码表");
//                tv2.setTextColor(Color.WHITE);
//                tv2.setTextSize(30);
//                mLoopRotarySwitchView.addView(tv2);
//
//                TextView tv3=new TextView(this);
//                tv3.setText("净化器");
//                tv3.setTextColor(Color.WHITE);
//                tv3.setTextSize(30);
//                mLoopRotarySwitchView.addView(tv3);
//
//                TextView tv4=new TextView(this);
//                tv4.setText("空调");
//                tv4.setTextColor(Color.WHITE);
//                tv4.setTextSize(30);
//                mLoopRotarySwitchView.addView(tv4);

//        allRect = new Rect[]{
//                new Rect(373*width/1280-width_d, 151*height/480-height_d, 777*width/1280, 285*height/480),
//                new Rect(555*width/1280-width_d, 194*height/480-height_d, 65*width/1280, 60*height/480),
//                new Rect(560*width/1280-width_d, 352*height/480-height_d, 50*width/1280, 52*height/480),
//                new Rect(668*width/1280-width_d, 197*height/480-height_d, 320*width/1280, 55*height/480),
//                new Rect(668*width/1280-width_d, 347*height/480-height_d, 422*width/1280, 55*height/480)
//        };

//        allRect[0] = new Rect(0, 200, 0, 0);
//        allRect[1] = new Rect(555*width/1280, 194*height/480, 0, 0);
//        allRect[2] = new Rect(600, 400, 0, 0);

//        for (int i=0; i<allRect.length; i++){
////        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(0, 0, FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(allRect[i].right-allRect[i].left, allRect[i].bottom-allRect[i].top);
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int)(allRect[i].right*density), (int)(allRect[i].bottom*density));
////        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ll_pay1.getLayoutParams();
//
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(allRect[i].right, allRect[i].bottom);
////            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(allRect[i].right, allRect[i].bottom);
//            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(allRect[i].right, allRect[i].bottom);
////            params.addRule(RelativeLayout.CENTER_IN_PARENT);
////            params.setMarginStart(allRect[i].left);
////            params.setMargins(allRect[i].left, allRect[i].top, allRect[i].right, allRect[i].bottom);
//            params.setMargins(allRect[i].left, allRect[i].top, 0, 0);
////          params.gravity=Gravity.CENTER;
//
////            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(allRect[i].right, allRect[i].bottom);
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 140*height/480);
////            params.setMargins(246*width/1280, 0, 0, 0);
////            params.set
//
////            TextView tv=new TextView(this);
////            tv.setText("中部");
////            tv.setTextSize(20);
////            addContentView(tv, params);
//
//            ImageView iv=new ImageView(this);
////            iv.setImageResource(imgSrc[i]);
//
//            iv.setScaleType(ImageView.ScaleType.FIT_XY);
//            iv.setImageResource(imgSrc[i]); //可用
//
////            iv.setLayoutParams(params);
////            addContentView(iv);
//            addContentView(iv, params);
//        }

//1280*480
//    Rect[] allRect;

//        for (int i=0; i<allRect.length; i++){
////        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(0, 0, FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(allRect[i].right-allRect[i].left, allRect[i].bottom-allRect[i].top);
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int)(allRect[i].right*density), (int)(allRect[i].bottom*density));
////            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(allRect[i].right, allRect[i].bottom);
//            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(allRect[i].right, allRect[i].bottom);
//            params.setMargins(allRect[i].left, allRect[i].top, allRect[i].right, allRect[i].bottom);
////        params.gravity=Gravity.CENTER;
//
////            TextView tv=new TextView(this);
////            tv.setText("中部");
////            tv.setTextSize(20);
////            addContentView(tv, params);
//
//            ImageView iv=new ImageView(context);
//            iv.setImageResource(imgSrc[i]);
//            iv.setScaleType(ImageView.ScaleType.FIT_XY);
//            v.addView(iv, params);
//
//            iv.setOnClickListener(new View.OnClickListener() {
//
//                @Override
//                public void onClick(View v) {
//                    ToastUtil.showMessageApp(context, "1");
//
//                    ImageView imageView = (ImageView)v;
//
//                    int imgid=0;
//                    try {
//                        Field[] fields = imageView.getClass().getDeclaredFields();
//
//                        Log.e("imgid===0", fields.length+"==="+fields);
//
//
//                        for(Field f:fields){
//
//                            Log.e("imgid===", "==="+f.getName());
//
//                            if(f.getName().equals("mResource")){
//                                f.setAccessible(true);
//
//                                imgid = f.getInt(imageView);
//
//                                if(imgid==R.drawable.light){
//                                    iv.setImageResource(R.drawable.light2);
//                                }else if(imgid==R.drawable.light2){
//                                    iv.setImageResource(R.drawable.light);
//                                }else if(imgid==R.drawable.light_fw){
//                                    iv.setImageResource(R.drawable.light_fw2);
//                                }else if(imgid==R.drawable.light_fw2){
//                                    iv.setImageResource(R.drawable.light_fw);
//                                }
//
//
//
//                            }
//
//                        }
//                    } catch (Exception e) {
//                        Log.e("imgid===e", "==="+e);
//                        e.printStackTrace();
//
//                    }
//
//
//                    /* 串口发送字节 */
////                    try {
////                        ttyS1OutputStream.write(bytes);   //TODO
////                    } catch (Exception e) {
////                        e.printStackTrace();
////                    }
//
//    //                /* 串口接受字节 */
//    //                ttyS1InputStream.read(bytes);
//                }
//            });
//        }

//        //定义了一个RelativeLayout ，LayoutParams 是控件属性
//        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(100, 100);
////        params.gravity = Gravity.BOTTOM|Gravity.RIGHT;
//        params.setMargins(0, 0, 50, 50);
////        RelativeLayout returnLayout = new RelativeLayout(activity);
////        returnLayout.setPadding(50, 10, 50, 50);
//        //这里是我自己背景资源
////        returnLayout.setBackgroundResource(R.drawable.beijing);
//
//
//        //定义了一个Button，
//        FrameLayout.LayoutParams returnButtonparams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
//        Button returnbutton = new Button(context);
////        returnbutton.setBackgroundResource(R.drawable.flst_return_button);
//        returnbutton.setText("1");
//        returnbutton.setLayoutParams(returnButtonparams);
//
//        //Layout中添加Button
////        returnLayout.addView(returnbutton);
//        //View中添加layout
//        v.addView(returnbutton, params);
//
//
//        returnbutton.setOnClickListener(new OnClickListener() {
//
//            @Override
//            public void onClick(View v) {
//                ToastUtil.showMessageApp(context, "1");
//
//                /* 串口发送字节 */
//                try {
//                    ttyS1OutputStream.write(bytes);   //TODO
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//
////                /* 串口接受字节 */
////                ttyS1InputStream.read(bytes);
//            }
//        });


////        v = super.onCreateView(inflater, container, savedInstanceState);
//        /*定义LayoutParams 为了获得当前View的属性*/
//
////        ViewGroup.LayoutParams lpLayoutParams = v.getLayoutParams();
////        //设置View的高度，也可以设置其他属性
////        lpLayoutParams.height = 800;
////        v.setPadding(50, 50, 50, 50);
////        //LayoutParams 属性赋予Fragment当前的View
////        v.setLayoutParams(lpLayoutParams);
//
//        Button returnbutton = new Button(activity);
////        returnbutton.setBackgroundResource(R.drawable.flst_return_button);
//        returnbutton.setText("1");
////        returnbutton.setLayoutParams(returnButtonparams);
//
//        //Layout中添加Button
//        v.addView(returnbutton);

//                    int imgid=0;
//                    try {
//                        Log.e("imgid===0", "==="+imgid);
//                        Log.e("imgid===", imageView.getClass().getField("mResource")+"==="+imgid);
//
//                        imgid = imageView.getClass().getField("mResource").getInt(imageView);
//
//                        Log.e("imgid===1", imageView.getClass().getField("mResource")+"==="+imgid);
//
//                        if(imgid==R.drawable.light){
//                            iv.setImageDrawable(getResources().getDrawable(R.drawable.light2));
//                        }else if(imgid==R.drawable.light2){
//                            iv.setImageDrawable(getResources().getDrawable(R.drawable.light));
//                        }
//
//                    } catch (Exception e) {
//                        Log.e("imgid===e", "==="+e);
//                        e.printStackTrace();
//                    }

////                ((MainActivity)getActivity()).applyRotation(true, new Fragment_Second(), 0, 90);

//                String type2 = (String)obj[5];
//                if("zm".equals(type2)){
//                    Map<Integer, ImageView> map = new HashMap<>();
//                    map.put(imgBack, iv);
//
//                    zmList.add(map);
//                }else if("fw".equals(type2)){
//                    Map<Integer, ImageView> map = new HashMap<>();
//                    map.put(imgBack, iv);
//
//                    fwList.add(map);
//                }